package com.sq.shangcheng.result;

public class CodeMsg {
	
	private int code;
	private String msg;
	
	//通用的错误码
	public static CodeMsg SUCCESS = new CodeMsg(0, "success");
	public static CodeMsg SERVER_ERROR = new CodeMsg(300100, "服务端异常！");
	public static CodeMsg BIND_ERROR = new CodeMsg(300101, "参数校验异常：%s");
	public static CodeMsg REQUEST_ILLEGAL = new CodeMsg(300102, "验证码错误或请求非法！");
	public static CodeMsg ACCESS_LIMIT_REACHED= new CodeMsg(300104, "访问太频繁！");
	//登录模块 3002XX
	public static CodeMsg SESSION_ERROR = new CodeMsg(300210, "您还没有登录，请先登录!");
	public static CodeMsg PASSWORD_EMPTY = new CodeMsg(300211, "密码不能为空！");
	public static CodeMsg MOBILE_EMPTY = new CodeMsg(300212, "手机号不能为空！");
	public static CodeMsg MOBILE_ERROR = new CodeMsg(300213, "手机号错误！");
	public static CodeMsg MOBILE_NOT_EXIST = new CodeMsg(300214, "手机号不存在！");
	public static CodeMsg PASSWORD_ERROR = new CodeMsg(300215, "密码错误！");


	private CodeMsg( ) {
	}
			
	private CodeMsg( int code,String msg ) {
		this.code = code;
		this.msg = msg;
	}
	
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	
	public CodeMsg fillArgs(Object... args) {
		int code = this.code;
		String message = String.format(this.msg, args);
		return new CodeMsg(code, message);
	}

	@Override
	public String toString() {
		return "CodeMsg [code=" + code + ", msg=" + msg + "]";
	}
	
	
}
